<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<!-- #BeginTemplate "../../../openslp.dwt" -->

<!--
    
    Pristine 1.0
    
    Design copyright Matt Dibb 2006
    www.mdibb.net

    Please feel free to use and modify this template for use on your site.  I dont mind
    if you use it for your personal site or a commercial site, but I do insist that it is
    not sold or given away in some "50,000 Templates!" package or something like that.

-->

    <head profile="http://www.w3.org/2005/10/profile">
        <meta http-equiv="Content-Language" content="en-gb" />
        <meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
        <link rel="stylesheet" type="text/css" href="../../../site.css" />
        <link rel="stylesheet" type="text/css" href="../../../print.css" media="print" />
        <link rel="alternate" type="application/rss+xml" title="OpenSLP&#8230;Recent Activity" href="http://www.sourceforge.net/export/rss2_keepsake.php?group_id=1730" />
        <link rel="alternate" type="application/rss+xml" title="OpenSLP&#8230;News" href="http://www.sourceforge.net/export/rss2_projnews.php?group_id=1730" />
        <link rel="alternate" type="application/rss+xml" title="OpenSLP&#8230;File Releases" href="http://www.sourceforge.net/api/file/index/project-id/1730/mtime/desc/limit/20/rss" />
        <link rel="alternate" type="application/rss+xml" title="OpenSLP&#8230;Reviews" href="http://www.sourceforge.net/projects/openslp/reviews_feed.rss" />
		<link rel="shortcut icon" href="../../../images/openslp_favicon_256color_48px.ico" />
        <!-- #BeginEditable "Page%20Style%20and%20Scripts" -->
	    <!-- #EndEditable -->
        <!-- #BeginEditable "Page%20Title" -->
  <title>OpenSLP Programmers Guide - SLPOpen</title>
	    <!-- #EndEditable -->
    </head>
    <body>
        <div id="content">
            <div id="header">
            	<a href="http://openslp.org/">
				<img src="../../../images/openslp_logo_web_color_150px.jpg" alt="" /></a>
            </div>
            <div id="body">
                <!-- #BeginEditable "Left%20Navigation%20-%20Context%20Specific" -->

                <!-- #EndEditable -->
                <div id="links">
                    <p><a href="../../../index.html">About</a><br/>
                       what is openslp</p>
                    <p><a href="../../../download.html">Download</a><br/>
                       how to get openslp</p>
                    <p><a href="../../../contribute.html">Contribute</a><br/>
                       how to help out</p>
                    <p><a href="../../../documentation.html">Documentation</a><br/>
                       how to find out more</p>
                    <p><a href="../../../credits.html">Credits</a><br/>
                       who to blame</p>
                    <p><a href="http://sourceforge.net/projects/openslp"><img src="http://sflogo.sourceforge.net/sflogo.php?group_id=1730&amp;type=2" alt="Get OpenSLP at SourceForge.net. Fast, secure and Free Open Source software downloads"/></a></p>
                </div>

                <div id="main">
                <!-- #BeginEditable "Page%20Content" -->

<h2>SLPOpen<br />
<span id="breadcrumbs"><a href="index.html">OpenSLP Programmer's Guide</a> &raquo; SLP Handle Functions &raquo; <a href="SLPOpen.html">SLPOpen</a></span></h2>

<h3>Declaration</h3>

<pre>#include &lt;slp.h&gt;

<a href="SLPTypes.html#SLPEXP">SLPEXP</a> <a href="SLPError.html">SLPError</a> <a href="SLPTypes.html#SLPAPI">SLPAPI</a> SLPOpen(
    const char * <a href="#lang">lang</a>,
    <a href="SLPTypes.html#SLPBoolean">SLPBoolean</a>   <a href="#isasync">isasync</a>,
    <a href="SLPTypes.html#SLPHandle">SLPHandle</a> *  <a href="#phslp">phslp</a>);
</pre>

<h3>Description</h3>

<p>Returns an <tt>SLPHandle</tt> handle in the <tt>phslp</tt> 
parameter for the language locale passed in as the <tt>lang</tt> 
parameter. The client indicates if operations on the handle 
are to be synchronous or asynchronous through the <tt>
isasync</tt> parameter. The handle encapsulates the language 
locale for SLP requests issued through the handle, and any 
other resources required by the implementation. The return 
value of the function is an
<tt>SLPError</tt>
code indicating the status of the operation. Upon failure, 
the <tt>phslp</tt>
parameter is NULL.</p>

<p>An <tt>SLPHandle</tt> can only be used for one SLP API operation at a time. 
If the original operation was started asynchronously, any attempt to start an 
additional operation on the handle while the original operation is pending 
results in the return of an <tt>SLP_HANDLE_IN_USE</tt>
error from the API function. The <tt>SLPClose()</tt> API function terminates any 
outstanding calls on the handle. If an implementation is unable to support a 
asynchronous( resp. synchronous) operation, due to memory constraints or lack of 
threading support, the <tt>SLP_NOT_IMPLEMENTED </tt>flag may be returned when 
the isasync flag is <tt>SLP_TRUE</tt> (resp. <tt>SLP_FALSE</tt>).</p>

<p>In the OpenSLP implementation, SLPHandles are used to cache information that 
is costly to obtain (in terms of network usage and time).&nbsp; Since the 
RFC 2614 API does not specify functions&nbsp; to initialize the implementation 
library, OpenSLP keeps track of the number of SLPHandles that are open.&nbsp; 
Several global library data structures are initialized when the first SLPHandle 
is opened and maintained until the last SLPHandle is closed.&nbsp; Therefore, it 
is most efficient to leave SLPHandles open for as long as you will need them 
(often for the entire life of a process).&nbsp; If you can help it, 
DO NOT make a habit of opening and closing SLPHandles frequently.</p>

<h3>Parameters</h3>

<table nosave="" border="1" cellpadding="5">
  <tbody>
    <tr nosave="" valign="top">
      <td nosave=""><a name="lang"></a><tt>lang</tt></td>
      <td nosave="">A pointer to null terminated array of characters containing 
	  the RFC 1766 Language Tag for the natural language locale of requests and 
	  registrations issued on the handle.&nbsp; Pass in NULL or the empty string, &quot;&quot; 
	  to use the local the machine is configured to use.</td>
    </tr>
    <tr nosave="" valign="top">
      <td><a name="isasync"></a><tt>isasync</tt></td>
      <td nosave="">A <tt>SLPBoolean</tt> value indicating whether the
      <tt>SLPHandle</tt>
	  should be opened for asynchronous operation or not.</td>
    </tr>
    <tr nosave="" valign="top">
      <td><a name="phslp"></a><tt>phslp</tt></td>
      <td nosave="">A pointer to an <tt>SLPHandle</tt>, in which the open <tt>
	  SLPHandle</tt>
	  is returned.&nbsp; If an error occurs, the value upon return is NULL.</td>
    </tr>
  </tbody>
</table>

<h3>Returns</h3>

<table nosave="" border="1">
  <tbody>
    <tr>
      <td>SLP_AUTHENTICATION_FAILED</td>
      <td>If the SLP framework supports authentication, this error arises when a 
	  authentication on an SLP message failed.</td>
    </tr>
    <tr>
      <td>SLP_MEMORY_ALLOC_FAILED&nbsp;</td>
      <td>Out of memory error</td>
    </tr>
    <tr>
      <td>SLP_PARAMETER_BAD</td>
      <td>If a parameter passed into a function is bad, this error is returned.</td>
    </tr>
    <tr>
      <td>SLP_INTERNAL_SYSTEM_ERROR</td>
      <td>A basic failure of the API causes this error to be returned. This 
	  occurs when a system call or library fails. The operation could not 
	  recover.</td>
    </tr>
    <tr>
      <td>SLP_HANDLE_IN_USE</td>
      <td>Callback functions are not permitted to recursively call into the API 
	  on the same SLPHandle, either directly or indirectly. If an attempt is 
	  made to do so, this error is returned from the called API function.</td>
    </tr>
  </tbody>
</table>

<p>Be aware, especially if the call is async, of error codes that may be passed 
to the SLPRegReport() callback function.</p>

<h3>Status</h3>

<table nosave="" cellpadding="5">
  <tbody>
    <tr nosave="" valign="top">
      <td nosave="">OpenSLP 0.6.0</td>
      <td nosave="">Fully implemented as specified by RFC 2614, except for 
	  asynchronous operation.<br>
      </td>
    </tr>
  </tbody>
</table>

<br />
<h3>See Also</h3>

<p><a href="SLPClose.html">SLPClose</a></p>

<p id="breadcrumbs0">Prepared by: <a href="http://www.calderasystems.com">Caldera Systems Inc</a><br />
Maintained by: <a href="http://www.openslp.org/">openslp.org</a></p>

                <!-- #EndEditable -->
                </div>
            </div>

            <div id="footer">
                Copyright &copy; 2011 <a href="http://www.openslp.org/">openslp.org</a>. All Rights Reserved.<br/>
                Design by <a href="http://www.mdibb.net" title="Website of Matt Dibb">Matt Dibb</a>
                2006. <a href="http://jigsaw.w3.org/css-validator/check/referer" title="Validate CSS">CSS</a> 
                <a href="http://validator.w3.org/check/referer" title="Validate XHTML">XHTML</a>
                <br/>Courtesy of <a href="http://www.openwebdesign.org">Open Web Design</a>
                &amp; <a href="http://seo-services.us">seo</a>
            </div>
        </div>
    </body>
<!-- #EndTemplate -->
</html>
